<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div id="app">
      <p>欢迎光临vue开发的收银系统 水果店</p>
      <p>苹果10￥/斤，折扣<8 折></p>
      <p>请输入你要购买的斤数<input type="text" v-model="num" /></p>
      <button @click="add()">结账买单</button>
      <p>结账单：总价：{{total}}￥元 折后价：{{dis}}￥元 省了：{{save}}￥元</p>
    </div>
    <script src="../vue.js"></script>
    <script>
      const app = new Vue({
        el: '#app',
        data: {
          num: '',
          total: '',
          dis: '',
          save: ''
        },
        computed: {
          add() {
            this.total = this.num * 10
            this.dis = this.total * 0.8
            this.save = this.total - this.dis
          }
        }
      })
    </script>
  </body>
</html>
